package com.world.lzh.interceptor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @version 1.0
 * @Author lzh
 * @Date 2022/4/26 - 21:53
 * @Description 注入拦截器
 **/
@Component
public class InterceptorConfig implements WebMvcConfigurer {

    @Autowired
    private CommonInterceptor commonInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(commonInterceptor)
                .addPathPatterns("/test/login")//拦截的路径
                .excludePathPatterns("/test/get");//不拦截的路径
    }
}
